"""Definition of the jiaolian content type
"""

from zope.interface import implements

from Products.Archetypes import atapi
from Products.ATContentTypes.content import base
from Products.ATContentTypes.content.image import ATImage,ATImageSchema
from Products.ATContentTypes.content import schemata

# -*- Message Factory Imported Here -*-
from my315ok.xtjxwcontents import xtjxwcontentsMessageFactory as _

from my315ok.xtjxwcontents.interfaces import Ijiaolian
from my315ok.xtjxwcontents.config import PROJECTNAME

jiaolianSchema = ATImageSchema.copy() + atapi.Schema((

    # -*- Your Archetypes field definitions here ... -*-

    

    atapi.StringField(
        'name',
        storage=atapi.AnnotationStorage(),
        widget=atapi.StringWidget(
            label=_(u"Name"),
            description=_(u"jiaolian name"),
        ),
        required=True,
    ),



    atapi.IntegerField(
        'price',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"youhuijiage"),
            description=_(u"youhuijiage"),
        ),
        required=True,
        default=3370,        
        validators=('isInt'),
    ),


    atapi.StringField(
        'district',
        storage=atapi.AnnotationStorage(),
        vocabulary_factory=u"my315ok.xtjxw.bigarea",
        enforceVocabulary=True,
        widget=atapi.SelectionWidget(
            label=_(u"diqu"),
            description=_(u"suoshudiqu"),           
        ),
        required=True,
        default="xiangtanshihexi",
    ),

    
    atapi.IntegerField(
        'chekuangzhishu',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"chekuangzhishu"),
            description=_(u"chekuangzhishu,0-10,10 is the best"),
        ),
        default=5,
        validators=('isInt'),
    ),


    atapi.IntegerField(
        'jishuzhishu',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"jishuzhishu"),
            description=_(u"jishu,0-10,10 is the best"),
        ),
        default=5,
        validators=('isInt'),
    ),


    atapi.IntegerField(
        'shoufei',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"shoufeizhishu"),
            description=_(u"shoufeizhishu,0-10,10 is the best"),
        ),
        default=5,
        validators=('isInt'),
    ),


    atapi.IntegerField(
        'fuwuzhishu',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"fuwuzhishu"),
            description=_(u"fuwuzhishu"),
        ),
        default=5,
        validators=('isInt'),
    ),
    atapi.IntegerField(
        'renqizhishu',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"renqizhishu"),
            description=_(u"renqizhishu"),
        ),
        default=100,
        validators=('isInt'),
    ),


    atapi.IntegerField(
        'jiaoling',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"jiaoling"),
            description=_(u"jiaoling"),
        ),
        required=True,
        default=3,
        validators=('isInt'),
    ),


    atapi.TextField(
        'contact_info',
        storage=atapi.AnnotationStorage(),
        widget=atapi.TextAreaWidget(
            label=_(u"contact information"),
            description=_(u"contact information"),
        ),
        required=True,
        default="13873298832",
    ),
    atapi.TextField(
        'jieshao',
        storage=atapi.AnnotationStorage(),
        default_output_type='text/html',
        widget=atapi.RichWidget(
            label=_(u"jiaolian jianjie"),
            rows=3,
            description=_(u"jiaolian jianjie"),
        ),
    ),


))

# Set storage on fields copied from ATContentTypeSchema, making sure
# they work well with the python bridge properties.

jiaolianSchema['title'].storage = atapi.AnnotationStorage()
jiaolianSchema['description'].storage = atapi.AnnotationStorage()
jiaolianSchema['description'].widget.visible = 0
jiaolianSchema['jieshao'].widget.allow_file_upload=False

schemata.finalizeATCTSchema(jiaolianSchema, moveDiscussion=False)


class jiaolian(ATImage):
    """Description of the Example Type"""
    implements(Ijiaolian)

    meta_type = "jiaolian"
    schema = jiaolianSchema

    title = atapi.ATFieldProperty('title')
    description = atapi.ATFieldProperty('description')

    # -*- Your ATSchema to Python Property Bridges Here ... -*-
    jieshao = atapi.ATFieldProperty('jieshao')

    name = atapi.ATFieldProperty('name')
    price = atapi.ATFieldProperty('price')
    district = atapi.ATFieldProperty('district')
    renqizhishu = atapi.ATFieldProperty('renqizhishu')
    
    chekuangzhishu = atapi.ATFieldProperty('chekuangzhishu')
    
    jishuzhishu = atapi.ATFieldProperty('jishuzhishu')
    
    shoufei = atapi.ATFieldProperty('shoufei')
    
    fuwuzhishu = atapi.ATFieldProperty('fuwuzhishu')

    jiaoling = atapi.ATFieldProperty('jiaoling')
    

    contact_info = atapi.ATFieldProperty('contact_info')


atapi.registerType(jiaolian, PROJECTNAME)
